package com.AIDS.AIDSweeper.server.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.google.appengine.api.datastore.Key;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable
public class Player {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;
	
	@Persistent
	private String login;
	
	@Persistent
	private String password;
	
	@Persistent
	private String status;
	
	@Persistent
	private int wins;
	
	@Persistent
	private int losses;
	
	@Persistent
	private String sessionHash;
	
	@Persistent
	private Date sessionExpire;
	
	@Persistent
	private List<Key> Gamers;

	public Player(String login, String password, String status,
			int wins, int losses, String sessionHash, Date sessionExpire) {
		super();
		this.login = login;
		this.password = password;
		this.status = status;
		this.wins = wins;
		this.losses = losses;
		this.sessionHash = sessionHash;
		this.sessionExpire = sessionExpire;
		Gamers = new ArrayList<Key>();
	}

	public Key getId() {
		return id;
	}

	public void setId(Key id) {
		this.id = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public int getWins() {
		return wins;
	}

	public void setWins(int wins) {
		this.wins = wins;
	}

	public int getLosses() {
		return losses;
	}

	public void setLosses(int losses) {
		this.losses = losses;
	}

	public String getSessionHash() {
		return sessionHash;
	}

	public void setSessionHash(String sessionHash) {
		this.sessionHash = sessionHash;
	}

	public Date getSessionExpire() {
		return sessionExpire;
	}

	public void setSessionExpire(Date sessionExpire) {
		this.sessionExpire = sessionExpire;
	}
	
	public void addGamer(Key newGamer) {
		Gamers.add(newGamer);
	}
	
	public void removeGamer(Key oldGamer) {
		Gamers.remove(oldGamer);
	}
	
	public List<Key> getGamers() {
		return Gamers;
	}

	public void setGamers(List<Key> gamers) {
		Gamers = gamers;
	}
	
	@Override
	public String toString() {
		return "<login>"+login+"</login>\n<status>"+status+"</status>\n<wins>"+wins+"</wins>\n<losses>"+losses+"</losses>";
	}
}
